"use strict";

/**
 * @ngdoc function
 * @name jgappApp.controller:ProjectChoosedataCtrl
 * @description
 * # ProjectChoosedataCtrl
 * Controller of the jgappApp
 */
angular
  .module("jgappApp")
  .controller("ProjectChoosedataCtrl", function(
    $scope,
    $routeParams,
    Util,
    openApi,
    PagingService,
    localStorageService
  ) {
    var projectParams = localStorageService.get("projectParams");
    var param = Object.assign({}, projectParams);
    console.log(projectParams);
    // 选择后回传的数据
    $scope.choosePeople = function(index) {
      $scope.submit(index);
    };
    $scope.submit = function(index) {
      if ($scope.taskList.items) {
        // 返回的字段value
        // 如果把需要的key直接挂载在result上面则需要这个方法，否则不用过滤直接返回
        var filterData = Util.filterSelectData(
          $scope.taskList.items[index],
          $scope.taskList.valuePropertys
        );
        localStorageService.set("projectreldata", filterData);
        // relModuleObj包含用来回显的值以及返回的内容
        Util.goBack();
      }
    };
    $scope.keyWrod = param.keyWrod;
    $scope.search = function(keyWrod) {
      param.keyWrod = keyWrod;
      param.functionId = $routeParams.flag;
      $scope.taskList = new PagingService(openApi.getLinkedpage, param);
    };
    $scope.search();
  });
